package main

import (
	"io/ioutil"
	"math/rand"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"time"
)

func main() {

	for {
		for i := 0; i < 5; i++ {
			rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
			deviceId := rnd.Intn(976758578569549)
			println(deviceId)

			sssss(deviceId)
			time.Sleep(time.Millisecond * 600)
		}
		time.Sleep(time.Second)
	}

}

var client = &http.Client{}

func sssss(deviceId int) {

	postData := url.Values{
		"cmd":      {"vote"},
		"uid":      {"6"},
		"deviceId": {strconv.Itoa(deviceId)},
		"token":    {"00b15f424c959fi126FYJbjMuwg7SJT1L9DjycURyMFEWj2YoDCVeph"},
	}
	urlStr := "http://www.yindudigital.cn/zj/20170825/api.php"
	req, _ := http.NewRequest("POST", urlStr, strings.NewReader(postData.Encode()))
	req.Header.Set("Host", "www.yindudigital.cn")
	req.Header.Set("Connection", "keep-alive")
	req.Header.Set("Content-Length", "101")
	req.Header.Set("Accept", "application/json, text/plain, */*")
	req.Header.Set("Origin", "http://www.yindudigital.cn")
	req.Header.Set("X-Requested-With", "XMLHttpRequest")
	req.Header.Set("User-Agent", "Mozilla/5.0 (Linux; Android 4.4.2; MX4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 iflytek_mmp ifly_lingxi")
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("Referer", "http://www.yindudigital.cn/zj/20170825/lx.php")
	//req.Header.Set("Accept-Encoding", "gzip,deflate")
	req.Header.Set("Accept-Language", "zh-CN,en-US;q=0.8")
	//req.Header.Set("Cookie", "PHPSESSID=3rdpbbhf98sj3ql9fs41q3en91")
	req.Header.Set("Cookie", "PHPSESSID=3rdpbbhf98sfhql9fs41q3en91")

	resp, err := client.Do(req)
	if err != nil {
		println(err.Error())
		return
	}
	body, _ := ioutil.ReadAll(resp.Body)
	println(string(body))
	defer resp.Body.Close()

}
